package com.lineage.server.serverpackets;

import com.lineage.list.Announcements;
import java.util.ArrayList;
import java.util.Iterator;

public class S_CommonNews extends ServerBasePacket {
  private byte[] _byte;
  
  public S_CommonNews() {
    this._byte = null;
    ArrayList<String> info = Announcements.get().list();
    writeC(48);
    StringBuilder messagePack = new StringBuilder();
    Iterator<String> iterator = info.iterator();
    while (iterator.hasNext()) {
      String message = iterator.next();
      messagePack.append(String.valueOf(String.valueOf(message)) + "\n");
    } 
    writeS(messagePack.toString());
  }
  
  public S_CommonNews(String s) {
    this._byte = null;
    writeC(48);
    writeS(s);
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
